package com.jeomo.common.quartz.provider.web.controller;

import com.jeomo.common.core.result.CommonResult;
import com.jeomo.common.core.util.AliOssUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * <h3>jeomo</h3>
 * <p>只是测试文件上传</p>
 *
 * @author : 崔贺
 * @date : 2020-09-03 11:02
 **/
@Controller
@RequestMapping("/")
public class UploadController {
    @Resource
    private AliOssUtils aliOssUtils;

    @RequestMapping("upload")
    public String picUpload(MultipartFile file) throws IOException {
        String originalFilename = file.getOriginalFilename();
        System.out.println("***********" + originalFilename + "********");
        CommonResult<String> upload = aliOssUtils.upload(file.getInputStream(), originalFilename);
        System.out.println("***********" + upload.getData() + "********");
        return upload.getData();
    }
}